<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2016/10/8
 * Time: 23:06
 */
header('Content:text/html;charset=utf-8');
?>
<html>
<head>
    <style>
        table{width: 100%;border: none;text-align: center;}
      tr{margin: inherit;width: 100%;height: 80px;font-size: 20px;}
       td{width: 200px;border: solid 1px; }
    </style>
</head>
<body>
   <div>
       <h1 align="center">商品订货单</h1>
<?php
   $goods=array(
    array('name'=>'主板','price'=>'379','producting'=>'广东','num'=>'3'),
    array('name'=>'显卡','price'=>'799','producting'=>'上海','num'=>'2'),
    array('name'=>'硬盘','price'=>'589','producting'=>'北京','num'=>'5'),
     );
$total=0;
$str="<table>";
$str.="<tr bgcolor='#e6e6fa'><td>商品名称</td><td>价格（元）</td><td>产地</td>";
$str.="<td>数量（件）</td><td>总价（元）</td></tr>";
foreach ($goods as $values) {
    $str .= '<tr>';
    foreach ($values as $v) {
        $str .= '<td>' . $v . '</td>';
    }
    $sum = $values['price'] * $values['num'];
    $str .= '<td>' . $sum . '</td>';
    $str .= '</tr>';
    $total += $sum;
}
$str.="<tr><td colspan='5' align='right'>小计：".$total."元</td>></tr></table>";
echo $str;
?>
    </div>
</body>
</html>

